cat

checking to see if an arg is a file and printing accordingly

checking to see if an arg is a file and printing accordingly I have the following code that takes in a file via an arg and if none exists, take it from stdin: file= column= pattern= path= cmd="echo" while getopts "f:c:e:" opt; do case $opt in f) file="$OPTARG";; c) column="$OPTARG";; e) pattern="$OPTARG";; *) echo "Usage: …

Total answers: 2

Getting a short string from a long one without spaces

Getting a short string from a long one without spaces I have a file with a huge string without spaces in it (something like: "A":123,"B":456,"C":789…) I want to get X amount of chars before and after a specific value (like what is around "B"). But, if I use cat, because the string doesn’t have spaces, …

Total answers: 1

What is the max size limit for using split and cat combination?

What is the max size limit for using split and cat combination? I have backed up a file in zip format on Ubuntu whose size is 6.5GB. Trying to transfer it to a USB stick so needed to split since I got error “file size too large” while copying. (Ideally I want my USB to …

Total answers: 1

How to concatenate files and give another name to output based on the match from another file?

How to concatenate files and give another name to output based on the match from another file? I have a directory data in which there are several fastqs like below: SRR13456784_1.fastq SRR13456784_2.fastq SRR13456784_3.fastq SRR13456785_1.fastq SRR13456785_2.fastq SRR13456785_3.fastq SRR13456786_1.fastq SRR13456786_2.fastq SRR13456786_3.fastq SRR19876543_1.fastq SRR19876543_2.fastq SRR19876543_3.fastq SRR19876544_1.fastq SRR19876544_2.fastq SRR19876544_3.fastq I have a details.txt delimited file, in which there two …

Total answers: 1

Merge files with same name in multiple subfolders

Merge files with same name in multiple subfolders I have multiple folders with a lot of files, Each folder has txt files of the same name, I want to merge files with the same name into one txt file. Example: folder/ -sub1 -sub2 -sub3 . . . -sub28 In each subfolder has a multiple files: …

Total answers: 2

Concatenating txt files and keeping directory name

Concatenating txt files and keeping directory name I am concatenating thousands of .txt files together but I want to keep the path written above the text of each .txt file so I can refer back to the directory to review files if needed. Example: file1.txt has the following content: id: 1234 info: 1234 id: abcd …

Total answers: 4

Redirecting the content of two files

Redirecting the content of two files I want to redirect the content of two files to a single file named ooo.txt. I also want to only take some specific lines of the second file using grep (in this case 5 lines before and 25 lines after ‘lol’) WITHOUT using parenthesis Here’s the command that I …

Total answers: 2

Getting the windows version of a "cat" command?

Getting the windows version of a "cat" command? I would like to have this script’s windows version cat name-of-APK.apk | openssl dgst -binary -sha256 | openssl base64 | tr ‘+/’ ‘-_’ | tr -d ‘=’ How can I get that? Asked By: Adam Varhegyi || Source You can actually use cat in PowerShell (which is …

Total answers: 2

How to create an alias for a "cat" file usable in a path

How to create an alias for a "cat" file usable in a path I have two huge files (150G each) and I need to use a tool for which I should supply them as a single file (since the tool only accepts one file). However, I do not want to merge these files for several …

Total answers: 2

How to replace cat with bat system-wide Ubuntu 22.04

How to replace cat with bat system-wide Ubuntu 22.04 I am using Ubuntu 22.04 with bash, pretty vanilla, and have added alias cat="batcat" to ~/.bashrc. The program batcat or bat being referred to can be found here: https://github.com/sharkdp/bat So, when I run cat ~/.bashrc, for instance, it outputs the contents of the file using batcat. …

Total answers: 4

Sed delete everything before and after characters

Sed delete everything before and after characters I’m running on android this Command: dumpsys activity activities | grep mFocusedApp Output: mFocusedApp=ActivityRecord{273535b u0 com.any.some/.app.AnyActivity t5595} Expected: com.any.some I need the package name only Either by sed or another direct command Edit (Copied from a comment to an answer; added to clarify that the resulting string shall …

Total answers: 4

"cat ls" messes up my terminal's characters

"cat ls" messes up my terminal's characters when I go to my /bin directory and do cat ls it messes up my whole terminal’s characters, even my input gets messed up and I have no option but to restart the terminal. I was just watching a toturial and the guy was doing this, his terminal …

Total answers: 1

Bash: variable is not full read in `for` because line contains blank spaces

Bash: variable is not full read in `for` because line contains blank spaces In for command, variable is not fully saved because of blank spaces. Source file in.csv: VPricingCurrency,Currency,Transactions,VPricingCurrency,Deal,VPricingCurrency CustomerPriceGroup,Customer Price Group,AccountDS,AccountType,AccountDS,AccountType Command: for i in $(cat in.csv); do echo "$i" done Output: VPricingCurrency,Currency,Transactions,VPricingCurrency,Deal,VPricingCurrency CustomerPriceGroup,Customer Price Group,AccountDS,AccountType,AccountDS,AccountType How to get second line full, with blank …

Total answers: 2

How to concatenate the first 100 files in a directory?

How to concatenate the first 100 files in a directory? I had 4000 text files with unique filenames in a directory. Is there any Linux command to concatenate only the 1-100 files. cat 1.txt … 100.txt > 1.100.txt cat 101.txt … 200.txt > 2.200.txt ……. ……. cat 3901.txt … 4000.txt > 40.4000.txt Suggestions please. Asked …

Total answers: 4

How to `sudo cat` the contents of a symlink

How to `sudo cat` the contents of a symlink I have created a symlink foo to the file /bar/baz using $ ln -s /bar/baz foo $ ls foo Here /bar/baz is a log file that only root has read permissions for. Now I would like to print the contents of /bar/baz using my symlink. But …

Total answers: 1

What are the benefits of this command line (/usr/bin/awk '{$1=$1};1') instead of pure cat

What are the benefits of this command line (/usr/bin/awk '{$1=$1};1') instead of pure cat I am reading the AWS eic_harvest_hostkeys script and I don’t understand this line: key=$(/usr/bin/awk ‘{$1=$1};1′ < "${file}") What is the of benefit awk? Isn’t key=$(/bin/cat "${file}") better? Asked By: K-att- || Source The assignment to $1 forces awk to rewrite the …

Total answers: 3