![]() Will return: sample-id,absolute-filepath,direction SampleR2=$(echo $R2 | sed 's/_R2_//')Ĭan you check by printing out fileR2 after you did fileR2=$(echo $fileR1 | sed 's/R1/R2/')?Īlso, you can add _R1_ when you use basename. # PATH to directory holding files, no trailing slash! The command used here is PWD, a print working directory, and once typed, the Linux Mint 20 system is requested to display the current location. Leaf-T1-FD-R2_S29_L001,/users/3052771/sharedscratch/Amplicon_data_july_2019/PN0086C_16S-137179427/Amplicon_2019_RNAseq/Leaf-T1-FD-R2_S29_L001_R2_,reverseĮcho "sample-id,absolute-filepath,direction" It will show the complete directory in the output, as shown below: pwd The above output shows that we are currently in the user’s directory, i.e., /home/aqsa. You can use similar logic in the script above to select the format.I am using below script to write the sample name, followed by path of the file and then for R1 it write forward and for R2 it writes reverse: but some of the file it do not write correctly, could you please suggest what is the problem: sample-id,absolute-filepath,direction The stat command returns the size in bytes as well. Using the stat command, we can display detailed information about a file or the file system. Feel free to improve it and tweak it to your needs. The image below shows how the script works.ĪNOTHER NOTE : The above script is pure barebones and is therefore open to significant improvements. I know how to get the file and /base/file using basename and dirname and also that using sed, but I can't get the base dir. base/file/file.tar I want to get '/base' from that. NOTE: We use a variating scale for the bc command to accommodate the number of decimals per evaluation. Hi guys, I need to get the base path from a full path to a file. We then use the bc command to convert file size in bytes to the specified format. We store the size in bytes as filesize.įinally, we implement a simple if statement to check if the size format is either 1 (Bytes), 2 (Kilobytes), 3 (Megabytes), 4 (Gigabyte). Since wc -c returns the file size in bytes and the file's path, we use AWK to grab only the file size. The next step calls the wc -c-command on the specified file. Next, we prompt the user for the file path and store this variable in a file. Bash reads this input and stores it to the format variable. In the script above, we start by asking the user to enter the file size format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |